package com.zhuoli.service.springboot.test.util.common;

import org.apache.commons.codec.digest.DigestUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: zhuoli
 * @Date: 2018/9/20 12:53
 * @Description:
 */
public class Signer {
    public static Map<String, String> sign(Map<String, Object> requestMap,
                                           String appKey,
                                           String password
    ) {
        Map<String, String> headerMap = new HashMap<>();
        String secret = password + JsonUtils.toJson(requestMap);
        String sign = DigestUtils.sha1Hex(secret);
        headerMap.put("App-Key", appKey);
        headerMap.put("Sign", sign);
        headerMap.put("Content-Type", "application/json");
        return headerMap;
    }
}
